<#include "/common/easyui-css.html">
<#include "/common/easyui-js.html">
<#include "/common/loading.html">
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<body class="easyui-layout">
<!-- 说明 字符串：Material，作为替换字符串 -->
<div class="easyui-layout" style="width:100%;height:100%;">
    <!-- 主表  -->
    <table id="month_table" class="easyui-datagrid" title="" style="width:100%;height:100%;padding-bottom: 2px;"
           data-options="rownumbers:true, pagination:true,singleSelect:true,
					  method:'get',
					  toolbar:'#tb',
					  fitColumns : true,
					  loadMsg : '数据加载中',
					  showFooter: true" >
        <thead>
        <th data-options="field:'mn',width:200,align:'center' ">原料</th>
        <th data-options="field:'sn',width:200,align:'center' ">供应商/采购商</th>
        <th data-options="field:'factotal',width:200,align:'center' ">厂家总计(总车数)</th>
        <th data-options="field:'mattotal',width:200,align:'center' ">同物料总计(总车数)</th>
        <th data-options="field:'type',width:200,align:'center' ">大类</th>
        <th data-options="field:'cattotal',width:200,align:'center' ">大类总计(总车数)</th>
        </thead>
    </table>
</div>

<!-- 搜索框 -->
<div id="tb" style="padding:5px;height:auto">
    <div>
        <input class="easyui-datebox" data-options="formatter:dateformatter,parser:dateparser" id="from" style="width:200px">
        分厂<select id="fac" class="easyui-combobox" name="fac" style="width:200px;">
            <option value="益隆">益隆</option>
            <option value="益达">益达</option>
        </select>

        <a href="#" class="easyui-linkbutton" iconCls="icon-search" id="searchByParameter">搜索</a>
    </div>
    <div style="margin:5px 0;"></div>
    <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-download'"  id="export">下载</a>
</div>

<!-- 按钮操作 -->
<script type="text/javascript">

    function dateformatter(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
    }
    function dateparser(s){
        if (!s) return new Date();
        var ss = (s.split('-'));
        var y = parseInt(ss[0],10);
        var m = parseInt(ss[1],10);
        var d = parseInt(ss[2],10);
        if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
            return new Date(y,m-1,d);
        } else {
            return new Date();
        }
    }
    $('#export').click(function(){

        var from = $('#from').val();
        var fac = $('#fac').val();
        window.location = "/in-month-download?from="+from+"&fac="+fac;
    });
    $('#searchByParameter').click(function () {
        var from = $('#from').val();
        var fac = $('#fac').val();
        var handler = '/month-list?from='+from+"&fac="+fac;
        $('#month_table').datagrid('options').url = handler;
        $('#month_table').datagrid('reload');

    })
</script>


